<?php

namespace App\Imports\Ekb;

use App\Models\Ekb\EkbBranchBankModel;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToCollection;

class BranchBankImport implements ToCollection
{
    /**
     * @param Collection $collection
     */
    public function collection(Collection $collection)
    {
        $collection->shift();

        $collection->each(function ($v, $k) {
            echo "第 {$k} 行" . PHP_EOL;
            EkbBranchBankModel::query()->insert([
                "branchId"   => $v->get(0),
                "branchName" => $v->get(1),
                "bankLinkNo" => $v->get(2),
                "cityId"     => $v->get(3),
                "bankId"     => $v->get(4),
                "updateTime" => $v->get(5)
            ]);
        });
    }
}
